www.gusucode.com > VC++ 视频采集与压缩、音频采集、加扰和解绕-源码程序 > VC++ 视频采集与压缩、音频采集、加扰和解绕-源码程序/code/VideoNet_src/decoder/DGlobal.cpp

    //Download by http://www.NewXing.com
////////////////////////////////////////////////////////////////////////////
//
//
//    Project     : VideoNet version 1.1.
//    Description : Peer to Peer Video Conferencing over the LAN.
//	  Author      :	Nagareshwar Y Talekar ( nsry2002@yahoo.co.in)
//    Date        : 15-6-2004.
//
//    This is the modified version of tmndecode (H.263 decoder) 
//    written by Karl & Robert.It was in ANSI C. I have converted into C++
//    so that it can be integrated into any windows application. I have 
//    removed some of the files which had display and file storing 
//    functions.I have removed the unnecessary code and also added some
//    new files..
//	  Original library dealt with files. Input & Output , both were files.
//    I have done some major changes so that it can be used for real time 
//    decoding process. Now one can use this library for decoding H263 frames. 
//
//
//    File description : 
//    Name    : DGlobal.cpp
//	  Details : Definitions of global variables.
//
/////////////////////////////////////////////////////////////////////////////


#include "DGlobal.h"



// Variable definitions....


   char version[200]="tmndecode v1.7\n(C) 1995, 1996 Telenor R&D\n";

   int quiet=1;  //keep quiet
   int trace=0;  //don't trace....
   char errortext[256];
   unsigned char *refframe[3],*oldrefframe[3],*bframe[3],*newframe[3];
   unsigned char *edgeframe[3], *edgeframeorig[3], *exnewframe[3];
   int MV[2][5][MBR+1][MBC+2];
   int modemap[MBR+1][MBC+2];
   unsigned char *clp;
   int horizontal_size,vertical_size,mb_width,mb_height;
   int coded_picture_width, coded_picture_height;
   int chrom_width,chrom_height,blk_cnt;
   int pict_type,newgob;
   int mv_outside_frame,syntax_arith_coding,adv_pred_mode,pb_frame;
   int long_vectors;
   int fault,expand;
   int verbose;
   int refidct;
   int matrix_coefficients;
   int temp_ref, prev_temp_ref, quant, source_format;
   int framerate;
   unsigned char *cframe=NULL;
   int csize;
   int cindex;
   struct ld  base,*ld;
   unsigned char *yp,*up,*vp;

   // log file for decoder...
   FILE *dlog=NULL;



  #ifndef WIN32
   struct timeval tftarget;
  #else
   unsigned int targetTime;
  #endif


   int roundtab[16]=  {0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2};

  //output
   char *outputname;
   int outtype;


   
   int trd, trb, bscan, bquant;
   int bscan_tab[]= {2,4,6,8};
   int bquant_tab[]= {5,6,7,8};


  
// zig-zag scan 
  unsigned char zig_zag_scan[64]=
  {
  0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,
  12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,
  35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,
  58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63
  };


// /*color space conversion coefficients
// *
// * entries are {crv,cbu,cgu,cgv}
// *
// * crv=(255/224)*65536*(1-cr)/0.5
// * cbu=(255/224)*65536*(1-cb)/0.5
// * cgu=(255/224)*65536*(cb/cg)*(1-cb)/0.5
// * cgv=(255/224)*65536*(cr/cg)*(1-cr)/0.5
// *
// * where Y=cr*R+cg*G+cb*B (cr+cg+cb=1)
// 

  int convmat[8][4]=
 {
  {117504, 138453, 13954, 34903}, //* no sequence_display_extension 
  {117504, 138453, 13954, 34903}, //* ITU-R Rec. 709 (1990) 
  {104597, 132201, 25675, 53279}, //* unspecified 
  {104597, 132201, 25675, 53279}, //* reserved 
  {104448, 132798, 24759, 53109}, //* FCC 
  {104597, 132201, 25675, 53279}, //* ITU-R Rec. 624-4 System B, G 
  {104597, 132201, 25675, 53279}, //* SMPTE 170M 
  {117579, 136230, 16907, 35559}  //* SMPTE 240M (1987) 
};




   int OM[5][8][8]= 
 {
{
  {4,5,5,5,5,5,5,4},
  {5,5,5,5,5,5,5,5},
  {5,5,6,6,6,6,5,5},
  {5,5,6,6,6,6,5,5},
  {5,5,6,6,6,6,5,5},
  {5,5,6,6,6,6,5,5},
  {5,5,5,5,5,5,5,5},
  {4,5,5,5,5,5,5,4},
},{
  {2,2,2,2,2,2,2,2},
  {1,1,2,2,2,2,1,1},
  {1,1,1,1,1,1,1,1},
  {1,1,1,1,1,1,1,1},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
},{
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {1,1,1,1,1,1,1,1},
  {1,1,1,1,1,1,1,1},
  {1,1,2,2,2,2,1,1},
  {2,2,2,2,2,2,2,2},
},{
  {0,0,0,0,1,1,1,2},
  {0,0,0,0,1,1,2,2},
  {0,0,0,0,1,1,2,2},
  {0,0,0,0,1,1,2,2},
  {0,0,0,0,1,1,2,2},
  {0,0,0,0,1,1,2,2},
  {0,0,0,0,1,1,2,2},
  {0,0,0,0,1,1,1,2},
},{
  {2,1,1,1,0,0,0,0},
  {2,2,1,1,0,0,0,0},
  {2,2,1,1,0,0,0,0},
  {2,2,1,1,0,0,0,0},
  {2,2,1,1,0,0,0,0},
  {2,2,1,1,0,0,0,0},
  {2,2,1,1,0,0,0,0},
  {2,1,1,1,0,0,0,0},
}
};




// 

 VLCtabI DCT3Dtab0[] = {
{4225,7}, {4209,7}, {4193,7}, {4177,7}, {193,7}, {177,7}, 
{161,7}, {4,7}, {4161,6}, {4161,6}, {4145,6}, {4145,6}, 
{4129,6}, {4129,6}, {4113,6}, {4113,6}, {145,6}, {145,6}, 
{129,6}, {129,6}, {113,6}, {113,6}, {97,6}, {97,6}, 
{18,6}, {18,6}, {3,6}, {3,6}, {81,5}, {81,5}, 
{81,5}, {81,5}, {65,5}, {65,5}, {65,5}, {65,5}, 
{49,5}, {49,5}, {49,5}, {49,5}, {4097,4}, {4097,4}, 
{4097,4}, {4097,4}, {4097,4}, {4097,4}, {4097,4}, {4097,4}, 
{1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
{1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
{1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
{1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
{1,2}, {1,2}, {1,2}, {1,2}, {1,2}, {1,2}, 
{1,2}, {1,2}, {17,3}, {17,3}, {17,3}, {17,3}, 
{17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, 
{17,3}, {17,3}, {17,3}, {17,3}, {17,3}, {17,3}, 
{33,4}, {33,4}, {33,4}, {33,4}, {33,4}, {33,4}, 
{33,4}, {33,4}, {2,4}, {2,4},{2,4},{2,4},
{2,4}, {2,4},{2,4},{2,4},
};


VLCtabI DCT3Dtab1[] = {
{9,10}, {8,10}, {4481,9}, {4481,9}, {4465,9}, {4465,9}, 
{4449,9}, {4449,9}, {4433,9}, {4433,9}, {4417,9}, {4417,9}, 
{4401,9}, {4401,9}, {4385,9}, {4385,9}, {4369,9}, {4369,9}, 
{4098,9}, {4098,9}, {353,9}, {353,9}, {337,9}, {337,9}, 
{321,9}, {321,9}, {305,9}, {305,9}, {289,9}, {289,9}, 
{273,9}, {273,9}, {257,9}, {257,9}, {241,9}, {241,9}, 
{66,9}, {66,9}, {50,9}, {50,9}, {7,9}, {7,9}, 
{6,9}, {6,9}, {4353,8}, {4353,8}, {4353,8}, {4353,8}, 
{4337,8}, {4337,8}, {4337,8}, {4337,8}, {4321,8}, {4321,8}, 
{4321,8}, {4321,8}, {4305,8}, {4305,8}, {4305,8}, {4305,8}, 
{4289,8}, {4289,8}, {4289,8}, {4289,8}, {4273,8}, {4273,8}, 
{4273,8}, {4273,8}, {4257,8}, {4257,8}, {4257,8}, {4257,8}, 
{4241,8}, {4241,8}, {4241,8}, {4241,8}, {225,8}, {225,8}, 
{225,8}, {225,8}, {209,8}, {209,8}, {209,8}, {209,8}, 
{34,8}, {34,8}, {34,8}, {34,8}, {19,8}, {19,8}, 
{19,8}, {19,8}, {5,8}, {5,8}, {5,8}, {5,8}, 
};

VLCtabI DCT3Dtab2[] = {
{4114,11}, {4114,11}, {4099,11}, {4099,11}, {11,11}, {11,11}, 
{10,11}, {10,11}, {4545,10}, {4545,10}, {4545,10}, {4545,10}, 
{4529,10}, {4529,10}, {4529,10}, {4529,10}, {4513,10}, {4513,10}, 
{4513,10}, {4513,10}, {4497,10}, {4497,10}, {4497,10}, {4497,10}, 
{146,10}, {146,10}, {146,10}, {146,10}, {130,10}, {130,10}, 
{130,10}, {130,10}, {114,10}, {114,10}, {114,10}, {114,10}, 
{98,10}, {98,10}, {98,10}, {98,10}, {82,10}, {82,10}, 
{82,10}, {82,10}, {51,10}, {51,10}, {51,10}, {51,10}, 
{35,10}, {35,10}, {35,10}, {35,10}, {20,10}, {20,10}, 
{20,10}, {20,10}, {12,11}, {12,11}, {21,11}, {21,11}, 
{369,11}, {369,11}, {385,11}, {385,11}, {4561,11}, {4561,11}, 
{4577,11}, {4577,11}, {4593,11}, {4593,11}, {4609,11}, {4609,11}, 
{22,12}, {36,12}, {67,12}, {83,12}, {99,12}, {162,12}, 
{401,12}, {417,12}, {4625,12}, {4641,12}, {4657,12}, {4673,12}, 
{4689,12}, {4705,12}, {4721,12}, {4737,12}, {7167,7}, 
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, 
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, 
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, 
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, 
{7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, {7167,7}, 
{7167,7}, };